package com.dxt.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * direct类型的exchange
 */
@Component
public class DirectModeConfig {
    public static final String EXCHANGE = "direct_exchange";
    public static final String ROUTING_KEY = "direct_routing_key";
    public static final String QUEUE = "direct_queue";

    @Bean
    public Queue directModeQueue(){
        return new Queue(DirectModeConfig.QUEUE);
    }
    @Bean
    public Exchange directModeExchange(){
        return new DirectExchange(DirectModeConfig.EXCHANGE, true, false);
    }

    @Bean
    public Binding directModeBinding(){
        return BindingBuilder.bind(directModeQueue()).to(directModeExchange()).with(DirectModeConfig.ROUTING_KEY).noargs();
    }
}
